home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 13 / CU Amiga Magazine's Super CD-ROM 13 (1997)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1997-08].iso / CUCD / Graphics / WildFire / WildFireFPU / Bonus / DragGadget.lha / dragclass / dragtest.c < prev   
C/C++ Source or Header  |  1996-12-24  |  3KB  |  96 lines

  1. #include "draggadget.h"
  2. #include <intuition/classes.h>
  3. #include <intuition/gadgetclass.h>
  4. #include <intuition/imageclass.h>
  5. #include <intuition/screens.h>
  6. #include <workbench/workbench.h>
  7.  
  8. #include <inline/stubs.h>
  9. #include <inline/intuition.h>
  10. #include <inline/exec.h>
  11. #include <inline/icon.h>
  12.  
  13. struct IntuitionBase *IntuitionBase=NULL;
  14. struct Library *IconBase=NULL;
  15. struct DClassLibrary *DragBase=NULL;
  16.  
  17. main()
  18. {
  19.   struct Gadget *dg1;
  20.   struct Window *win;
  21.   struct IntuiMessage *msg;
  22.   struct IClass *dc;
  23.   struct DiskObject *icon;
  24.   struct Image *image,*image2;
  25.   BOOL done=FALSE;
  26.  
  27.   if(DragBase=OpenLibrary("drag.gadget",0))
  28.   {
  29.     dc=DragBase->dcl_DragClass;
  30.     if( (IntuitionBase=(struct IntuitionBase*)OpenLibrary("intuition.library",37)) &&
  31.         (IconBase=OpenLibrary("icon.library",37)) )
  32.     {
  33.       if(win=OpenWindowTags(NULL,WA_Left,100,
  34.                                  WA_Top,100,
  35.                                  WA_Width,200,
  36.                                  WA_Height,200,
  37.                                  WA_Title,"drag&drop-test",
  38.                                  WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_GADGETUP|IDCMP_MOUSEBUTTONS,
  39.                                  WA_CloseGadget,TRUE,
  40.                                  WA_DragBar,TRUE,
  41.                                  WA_DepthGadget,TRUE,
  42.                                  WA_NoCareRefresh,TRUE,NULL))
  43.       {
  44.         if(icon=GetDiskObject("sys:Disk"))
  45.         {
  46.           image=icon->do_Gadget.GadgetRender;
  47.           image2=icon->do_Gadget.SelectRender;
  48.           if(dg1=NewObject(dc,NULL,GA_Left,20,
  49.                                    GA_Top,20,
  50.                                    GA_ID,1,
  51.                                    DGA_Screen,win->WScreen,
  52.                                    DGA_ExtSelect,TRUE,
  53.                                    GA_Image,image,
  54.                                    GA_SelectRender,image2,
  55.                                    GA_RelVerify,TRUE,
  56.                                    GA_Highlight,GFLG_GADGHIMAGE,NULL))
  57.           {
  58.             AddGadget(win,dg1,-1);
  59.             RefreshGList(dg1,win,NULL,1);
  60.             while(!done)
  61.             {
  62.               WaitPort(win->UserPort);
  63.               while(msg=GetMsg(win->UserPort))
  64.               {
  65.                 switch (msg->Class) {
  66.                   case IDCMP_CLOSEWINDOW:
  67.                     done=TRUE;
  68.                     break;
  69.                   case IDCMP_GADGETUP:
  70.                     {
  71.                       struct DragInfo *dr=(struct DragInfo*)((struct Gadget*)msg->IAddress)->SpecialInfo;
  72.                       printf("Gadget %d up; x: %d, y: %d\n",((struct Gadget*)msg->IAddress)->GadgetID,
  73.                                                             dr->mouse.X,dr->mouse.Y);
  74.                     }
  75.                     break;
  76.                   case IDCMP_MOUSEBUTTONS:
  77.                     if(msg->Code==SELECTDOWN)
  78.                       SetGadgetAttrs(dg1,win,NULL,GA_Selected,FALSE,NULL);
  79.                 }
  80.                 ReplyMsg(msg);
  81.               }
  82.             }
  83.             RemoveGadget(win,dg1);
  84.             DisposeObject(dg1);
  85.           }
  86.           FreeDiskObject(icon);
  87.         }
  88.         CloseWindow(win);
  89.       }
  90.       if(IntuitionBase) CloseLibrary((struct Library*)IntuitionBase);
  91.       if(IconBase) CloseLibrary(IconBase);
  92.     }
  93.     CloseLibrary(DragBase);
  94.   }
  95. }
  96.